import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StudentVO, StudentForm, StudentQuery } from '@/api/core/student/types';

/**
 * 查询学生信息列表
 * @param query
 * @returns {*}
 */

export const listStudent = (query?: StudentQuery): AxiosPromise<StudentVO[]> => {
  return request({
    url: '/core/student/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询学生信息详细
 * @param id
 */
export const getStudent = (id: string | number): AxiosPromise<StudentVO> => {
  return request({
    url: '/core/student/' + id,
    method: 'get'
  });
};

/**
 * 新增学生信息
 * @param data
 */
export const addStudent = (data: StudentForm) => {
  return request({
    url: '/core/student',
    method: 'post',
    data: data
  });
};

/**
 * 修改学生信息
 * @param data
 */
export const updateStudent = (data: StudentForm) => {
  return request({
    url: '/core/student',
    method: 'put',
    data: data
  });
};

/**
 * 删除学生信息
 * @param id
 */
export const delStudent = (id: string | number | Array<string | number>) => {
  return request({
    url: '/core/student/' + id,
    method: 'delete'
  });
};
